import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate"

import footer from './modules/footer'
import header from './modules/header'
import main from './modules/main'

Vue.use(Vuex)

export default new Vuex.Store({
  plugins: [createPersistedState({
    key: 'todos',
    paths: ['main'],
    // storage: window.sessionStorage
  })],

  modules: { footer, header, main },

  state: {

  },

  mutations: {

  },

  getters: {
    rlist ({ main, footer }) {
      if (footer.status === 'yes') {
        return main.list.filter(obj => obj.isDone)
      } else if (footer.status === 'no') {
        return main.list.filter(obj => !obj.isDone)
      } else {
        return main.list
      }
    }
  }
})